package com.tanhua.domain.vo;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class ErrorResult {
    private String errCode;
    private String errMessage;

    public static ErrorResult error() {
        return ErrorResult.builder().errCode("999999").errMessage("系统异常稍后再试").build();
    }

    public static ErrorResult smsSendFailed() {
        return ErrorResult.builder().errCode("000000").errMessage("发送验证码失败").build();
    }

    public static ErrorResult smsNotYetValid() {
        return ErrorResult.builder().errCode("000001").errMessage("上一次发送的验证码还未失效").build();
    }

    public static ErrorResult smsInvalid() {
        return ErrorResult.builder().errCode("000002").errMessage("验证码错误或已失效").build();
    }

    public static ErrorResult faceDetectFailed() {
        return ErrorResult.builder().errCode("000003").errMessage("图片非人像，请重新上传!").build();
    }

    public static ErrorResult publishSoundTimeOut() {
        return ErrorResult.builder().errCode("000004").errMessage("上传语音次数已用完！").build();
    }

    public static ErrorResult receiveSoundTimeOut() {
        return ErrorResult.builder().errCode("000005").errMessage("接收语音次数已用完！").build();
    }

    public static ErrorResult loginFrozen(Long time) {
        if (time > 0) {
            long ms = time - System.currentTimeMillis();
            double day = Math.ceil(ms * 1.0 / (1000 * 60 * 60 * 24));
            int dayOut = (int) day;
            return ErrorResult.builder().errCode("000006").errMessage("您的登录功能已被冻结，距离解封还有" + dayOut + "天").build();
        } else {
            return ErrorResult.builder().errCode("000006").errMessage("您的登录功能已被永久冻结").build();
        }
    }

    public static ErrorResult commentFrozen(Long time) {
        if (time > 0) {
            long ms = time - System.currentTimeMillis();
            double day = Math.ceil(ms * 1.0 / (1000 * 60 * 60 * 24));
            int dayOut = (int) day;
            return ErrorResult.builder().errCode("000006").errMessage("您的评论功能已被冻结，距离解封还有" + dayOut + "天").build();
        } else {
            return ErrorResult.builder().errCode("000006").errMessage("您的评论功能已被永久冻结").build();
        }
    }

    public static ErrorResult publishFrozen(Long time) {
        if (time > 0) {
            long ms = time - System.currentTimeMillis();
            double day = Math.ceil(ms * 1.0 / (1000 * 60 * 60 * 24));
            int dayOut = (int) day;
            return ErrorResult.builder().errCode("000006").errMessage("您的动态发布功能已被冻结，距离解封还有" + dayOut + "天").build();
        } else {
            return ErrorResult.builder().errCode("000006").errMessage("您的动态发布功能已被永久冻结").build();
        }
    }
}
